import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { SCrossSWPlayerScoreInfo } from "../../../../../Message/Public/SCrossSWPlayerScoreInfo";
import { Cache } from "../../../cache/Cache";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SEntityId } from "../../../../../Message/Public/SEntityId";
import { EEntityType } from "../../../../../Message/Public/EEntityType";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class AttachedSoulBattlefielApplyRenderer
    
    export  class AttachedSoulBattlefielApplyRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=0;
            super.data = arg1;
            if (typeof arg1 === "scrossswplayerscoreinfo") 
            {
                this._vo = arg1 as SCrossSWPlayerScoreInfo;
                loc1 = Cache.instance.attachedSoulBattlefield.applyList.indexOf(this._vo) + 1;
                this._rankTxt.text = loc1.toString();
                this._namTxt.htmlText = HTMLUtil.addLink(EntityUtil.getProxyNameByProxyAndServer(this._vo.proxyId, this._vo.serverId) + " " + this._vo.name, GlobalStyle.color1);
                this._integral.text = this._vo.score.toString();
                this._fightingTxt.text = this._vo.combat.toString();
                this._rateTxt.text = int(this._vo.winNum / this._vo.totalNum * 100) + "%";
                this._namTxt.textColor = Cache.instance.role.playerInfo.playerId != this._vo.playerId ? 16777215 : GlobalStyle.color5Uint;
            }
            return;
        }

        /* internal  */onNameTxtLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=null;
            if (this._vo) 
            {
                loc1 = new SEntityId();
                loc1.id = this._vo.playerId;
                loc1.type = EEntityType._EEntityTypePlayer;
                loc1.typeEx = this._vo.serverId;
                loc1.typeEx2 = this._vo.proxyId;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerInfo_view, loc1));
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            super.createChildren();
            loc1 = GlobalStyle.setTextFormatAlign(GlobalStyle._textFormatWhite, flash.text.TextFormatAlign.CENTER);
            this._rankTxt = ObjCreate.createGTextField("", 0, 7, 80, 20, this, loc1);
            this._rankTxt.mouseEnabled = false;
            this._namTxt = ObjCreate.createGTextField("", 80, 7, 160, 20, this, loc1);
            this._namTxt.addEventListener(flash.events.TextEvent.LINK, this.onNameTxtLinkHandler);
            this._integral = ObjCreate.createGTextField("", 240, 7, 130, 20, this, loc1);
            this._integral.mouseEnabled = false;
            this._fightingTxt = ObjCreate.createGTextField("", 370, 7, 130, 20, this, loc1);
            this._fightingTxt.mouseEnabled = false;
            this._rateTxt = ObjCreate.createGTextField("", 500, 7, 80, 20, this, loc1);
            this._rateTxt.mouseEnabled = false;
            ObjCreate.createBg(0, 30, 573, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal */ /* var */_rankTxt: GTextFiled;

        /* internal */ /* var */_namTxt: GTextFiled;

        /* internal */ /* var */_integral: GTextFiled;

        /* internal */ /* var */_fightingTxt: GTextFiled;

        /* internal */ /* var */_rateTxt: GTextFiled;

        /* internal */ /* var */_vo: SCrossSWPlayerScoreInfo;
    }
